package com.bree.erp.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;

@NamedQuery(name = Unit.QUERY_SELECT_ALL_UNIT, query="SELECT u FROM Unit u")
@Entity
public class Unit {

	public static final String QUERY_SELECT_ALL_UNIT = "selectAllUnit";

	public static final int COL_CODE_LEN = 10;
	public static final int COL_ABBREVIATION_LEN = 10;
	public static final int COL_DESCRIPTION_LEN = 255;
	
	@Id
	@Column(length=COL_CODE_LEN)
	private String code;

	@Column(length=COL_ABBREVIATION_LEN)
	private String abbreviation;

	@Column(length=COL_DESCRIPTION_LEN)
	private String description;
	
	@Override
	public boolean equals(Object obj) {
		
		if(obj instanceof Unit) {
			Unit that = (Unit) obj;
			if(this.code.equals(that.code)) {
				return true;
			}
		}
		
		return false;
	}
	
	@Override
	public int hashCode() {
		return code == null ? 0 : code.hashCode();
	}

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @return the abbreviation
	 */
	public String getAbbreviation() {
		return abbreviation;
	}

	/**
	 * @param abbreviation the abbreviation to set
	 */
	public void setAbbreviation(String abbreviation) {
		this.abbreviation = abbreviation;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	
}
